package com.patten.observer;

/**
 * Created with IntelliJ IDEA.
 * User: Lv.Dongjie
 * Date: 2018/8/6
 * Time: 15:16
 * Description:
 */
public class CurrentConditionDisplay implements Observer,DisplayElement {

    private float temperature;
    private float humidity;
    private Subject weatherData;

    public CurrentConditionDisplay(Subject weatherData ){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("Current condition:"+temperature+"F degrees and "+humidity+"% humidity");
    }

    @Override
    public void update(float temp ,float humidity, float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        //this.pressure = pressure;
        display();
    }
}
